from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.select import Select

# 酒仙网 收货地址  下拉选择框

driver=webdriver.Edge()
driver.maximize_window()
driver.get('https://www.jiuxian.com/')
driver.find_element(By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]').click()
time.sleep(3)
# 断言 账号登录
dy1=driver.find_element(By.CLASS_NAME,'userLogin.on').text
print(dy1)
time.sleep(3)
# 输入账号  userName
driver.find_element(By.ID,'userName').send_keys("13103053968")
time.sleep(3)
# 输入密码
driver.find_element(By.NAME,'_pwd').send_keys("jiuxianwang123aaa")
time.sleep(10)
# 点击登录按钮
driver.find_element(By.XPATH,'//*[@id="save"]').click()
time.sleep(6)
# 断言登录成功
dy2=driver.find_element(By.XPATH,'/html/body/div[2]/div/div[1]/div/p/span')
time.sleep(5)
print(dy2)
# 点击我的酒仙  https://member.jiuxian.com/index.htm
driver.find_element(By.XPATH,'//a[@href="https://member.jiuxian.com/index.htm"]').click()
time.sleep(5)
# 切换窗口
driver.switch_to.window(driver.window_handles[-1])
time.sleep(5)
# 点击收货地址
driver.find_element(By.LINK_TEXT,'收货地址').click()
time.sleep(3)
# 点击添加地址
driver.find_element(By.CLASS_NAME,'addressTrue').click()
time.sleep(3)
# 输入收货人
driver.find_element(By.ID,'people').send_keys("哈哈哈")
time.sleep(3)
# 选择地区  province  city  district
province=Select(driver.find_element(By.ID,'province'))
province.select_by_index(1)
time.sleep(3)
city=Select(driver.find_element(By.ID,'city'))
city.select_by_value('52')
district=Select(driver.find_element(By.ID,'district'))
district.select_by_visible_text('昌平区')
time.sleep(5)